//得到缓存
const getStorage = (key) => {
  const promise = new Promise(function (resolve, reject) {
    wx.getStorage({
      key: key,
      success: resolve,
      fail: reject
    })
  });
  return promise;
};

//设置缓存
const setStorage = (key, data) => {
  const promise = new Promise(function (resolve, reject) {
    wx.setStorage({
      key: key,
      data: data,
      success: resolve,
      fail: reject
    })
  });
  return promise;
};

// 获取code
const wxLogin = () => {
  const promise = new Promise(function (resolve, reject) {
    wx.login({
      success: resolve
    })
  });
  return promise;
}

module.exports = {
  getStorage,
  setStorage,
  wxLogin
}